<?PHP
session_start();

require("../../conexao/ConectaMysql.class.php");
require("../../conexao/ControleAcesso.class.php");

ControleAcesso::verificaSessao();
$ACE_PRIVid = $_SESSION['PRIVid'];

$conexao = new ConectaMysql();

if (isset($_POST['txtbuscar'])) {
	$txtbuscar = $_POST['txtbuscar'];

}else if (isset($_GET['txtbuscar'])) {
	$txtbuscar = $_GET['txtbuscar'];	
}else{
	$txtbuscar = "";	
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Setor</title>
<link href="../../estrutura/css/datagrid/light/estilo.css" rel="stylesheet" type="text/css" media="screen" />
<link href="../../estrutura/css/estruturaTotal.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div class="headerModulo"><img src="../../estrutura/imagens/ico_confirmacao.png" alt="" /> &nbsp;Registros</div>
<div class="filtros" style="display: block;">
 <form id="pesquisar" method="post" action="Formulario.php" name="pesquisar">
      <fieldset>
	     <span class="linha">
           <label class="preField" for="tipoServico">Localizar por:</label>
           <input id="txtbuscar" name="txtbuscar" type="text" value="<?php echo $txtbuscar; ?>"  size="40" class="caixa_texto">
           <input id="buscar" name="buscar" type="submit" value="Buscar" class="caixa_texto">
	     </span>
      </fieldset>
 </form>
</div>
<div class="datagrid_conteudo" id="datagrid_conteudo">
  <form id="datagrid_form_menus" name="datagrid_form_menus" action="formulario.php" onsubmit="return false">
    <table class="datagrid">
          
		<?php 
	 
		if ($txtbuscar != '') {
 			$txtbuscar = addslashes($txtbuscar);
			$sql_WHERE_txtbuscar = "((tb_setor.SETnome like '%$txtbuscar%') OR
			 						 (tb_setor.SETsigla like '%$txtbuscar%') OR
									 (tb_setor.SETdata like '%$txtbuscar%')) AND ";
		} else {
			
			$sql_WHERE_txtbuscar = "";
		}
			
		$querySetor = "SELECT * FROM tb_setor WHERE ($sql_WHERE_txtbuscar (tb_setor.SETstatus='1')) ORDER BY SETsigla" ;
								 
			 
		$quantreg = $conexao->rowCount($querySetor);	
 
		?>

        <tr>
        	<td colspan="4" class="alinCentro"><?php include("../../estrutura/paginacao.php"); ?></td>
        </tr>
        
        <tr class="header">
            <th width="377" class=" alinCentro " style="">Setor</th>
            <th width="262" class=" alinCentro " style="">Sigla</th>
            <th width="390" class=" alinCentro " style="">Data Cadastro</th>
            <?php if($ACE_PRIVid == 1){ ?><th width="86" class=" alinCentro " style="">Op&ccedil;&otilde;es</th><?php }?>
        </tr>

		<?php
	
		$result_setor = $conexao->executaQuery("$querySetor LIMIT $inicial, $numreg");
		  
		foreach($result_setor as $row_setor){  

	 		$SETid		= $row_setor["SETid"];
			$SETsigla	= $row_setor["SETsigla"];
			$SETdata	= $row_setor["SETdata"];
			$SETnome	= $row_setor["SETnome"];
			
		?>	
        <tr id="datagrid_menus_linha_0" class="">
        <td class=" alinEsquerda "><span class="texto style57 style59 style41"><?php echo "$SETnome"; ?></span></td>          
        <td class=" alinEsquerda "><span class="texto style57 style59 style41"><?php echo "$SETsigla"; ?></span></td>
        <td class=" alinEsquerda "><span class="texto style57 style59 style41"><?php echo "$SETdata"; ?></span></td>        
        <?php if($ACE_PRIVid == 1){ ?><td width="86" class=" alinCentro "><a title="Alterar" class="botaoDatagrid alterar" href="alterar_setor.php?SETid=<?php echo "$SETid" ;?>">&nbsp;</a>  </td><?php }?>
        </tr>
		<?php } ?>  
    </table>     
  </form>
 </div> 
</body>
</html>
